A new property of the last non-zero digit of factorials
-------------------------------------------------------

    I discovered a property of the last non-zero digit of factorials of powers
of ten.

Property - If k is not equal to 1, the last non-zero digit of (10^k)! is equal
           to the last non-zero digit of (2^k)!.

    This property is interesting, and because 10^k grows much faster than 2^k,
it can be used to reduce the execution time of computations of the last non-zero
digit of factorials. (In the particular case of factorials of N, N a power of
10.)

    Given an integer n, the value of the last non-zero digit of n!, a(n), can be
determined by the third formula of OEIS sequence A008904, namely,

a(0) = 1, a(1) = 1, if n >= 2, with
n represented in base 5 as (a_h, ... ,a_1,a_0)5,
t = sum{i = h, h-1, ... , 0} (a_i even),
x = sum{i=h, h-1, ... , 1}(sum{k=h, h-1, ... , i}(a_i)),
z = (x + t/2) mod 4, and y = 2^z,
a(n) = 6(y mod 2) + y(1-(y mod 2)).


    To prove the validity of the given property we can show that the formula
above gives the same value of a(n) in both cases, n = 10^k, or n = 2^k. In other
words,

a(10^k) = a(2^k).                                                            (1)

    With the sum x calculated for n = 2^k, let x10 be the value of this sum, if
n = 10^k instead. For a given k, all the digits of (2^k)5 coincide, one by one,
from left to right, with the initial digits of (10^k)5, and k zeros appear in
(10^k)5 after those coincident digits, see A055476 for details. From this fact
it is not difficult to see that x10 satisfies the identity,

x10 = x + k*s,

where s is the sum of the digits of (2^k)5.

    The proof is complete since the value of z is not modified if 10^k replaces
2^k. Note that the sum t remains the same if we substitute 2^k by 10^k, and s
mod 4 = 0 because the digit sum of (2^k)5, s, is divisible by 4 when k > 1. See
A053824.
***

    For example, let k=9. 2^9 = 512 = (4022)5, and 10^9 = (4022000000000)5. Note
that all the digits of (2^9)5 coincide, one by one, from left to right, with the
initial digits of (10^9)5, and k zeros appear in (10^9)5 after those coincident
digits.
    In this case h = 3, x = 4 + (4+0) + (4+0+2) = 14, s = 8, and t/2 = 4. We
have x10 = (4 + (4+0) + (4+0+2)) + (4+0+2+2) + 8(4+0+2+2) = x + 9s. The value of
z is 2. Note that z = (x + t/2) mod 4 = (x10 + t/2) mod 4 = (x + k*s + t/2) mod
4.
-------------------

    The identities (2), (3), and (4) below are mentioned in [1].

    For n >= 5, and n mod 5 = 0, the value calculated by the formula above for a
given value of n does not change, if n+1 is given to the formula instead. This is
true because all the digits of (n + 1)5 coincide, one by one, from left to right,
with the digits of (n)5, with the exception of the last digit, which is 1, or 0,
respectively for (n + 1)5, and (n)5. The value of t will be constant, since in t
we sum the even digits, and x also will be the same, in both cases, n, n+1,
since we do not sum the last digit in x. A similar argument can be used for the
case n vs. n+3. We have,

a(n) = a(n+1) = a(n+3).                                                      (2)


    Above we discuss the case n vs. n+1. When n+2 replaces n, x will be the same
because only the last digit changes. The value of t raises 2 units, and t/2
changes to t/2 + 1. We have four cases, if for n, z is 2, for n+2, z will be 3,
and is easy to see that z changes from 0 to 1, from 1 to 2, and from 3 to 0. It is
clear that the value of a(n) goes from 4 (when z = 2) to 8, 6 becomes 2, 2 becomes
4, and 8 becomes 6. In all the four cases we have,


a(n+2) = 2a(n) mod 10.                                                       (3)

    When n+4 replaces n, x will be the same. The value of t raises 4 units, and
t/2 changes to t/2 + 2. If for n, z is 2, for n+4, z will be (2 + 2) mod 4 = 0.
It is easy to see that z changes from 0 to 2, from 1 to 3, and from 3 to 1. The
value of a(n) goes from 4 (when z = 2) to 6, 6 becomes 4, 2 becomes 8, and 8
becomes 2. In all the four cases we have,

a(n+4) = 4a(n) mod 10.                                                      (4)

------------------

References
[1] http://home.wlu.edu/~dresdeng/papers/two.pdf
